<?php

//create the xml document
$xmlDoc = new DOMDocument();

//create the root element
$logs = $xmlDoc->appendChild(
          $xmlDoc->createElement("logs"));


	if (!$file = fopen("res","r")) {
	//echo "Echec de l'ouverture du fichier";

	exit;
	}
	else 
	{
		$cmp = 0;
		while(!feof($file)) 
		{
		 
			$lines = fgets($file,1024);
			$res = explode("|", $lines);		 	

			if(!empty($res[0])) 
			{	

				  $line = $logs->appendChild(
					      $xmlDoc->createElement("line"));
				  $line->appendChild(
				    $xmlDoc->createElement("Id", $res[0]));
				 
				  $LineAttributes = $line->appendChild(
					      $xmlDoc->createElement("LineAttributes"));
				  $LineAttributes->appendChild(
				    $xmlDoc->createElement("User", $res[1]));
				  $LineAttributes->appendChild(
				    $xmlDoc->createElement("Status", $res[2]));
				  $LineAttributes->appendChild(
				    $xmlDoc->createElement("App", $res[3]));
				  $LineAttributes->appendChild(
				    $xmlDoc->createElement("Filename", $res[4]));			
			
			}
			else
			{
				header("Content-Type: text/xml");
				$xmlDoc->formatOutput = true;
				 
			}
	
		}
		fclose($file);  
	}
echo $xmlDoc->saveXML();
 
?>
